# Maintainer: Jelle van der Waa <jelle@vdwaa.nl>
# Maintainer: Eli Schwartz <eschwartz@archlinux.org>
# Contributor: Alexander Rødseth <rodseth@gmail.com>
# Contributor: Angel 'angvp' Velasquez <angvp[at]archlinux.com.ve>
# Contributor: Roman Kyrylych <Roman.Kyrylych@gmail.com>
# Contributor: iom <pizorn@gmail.com>

pkgname=python-pychm
pkgver=0.8.6
pkgrel=7
pkgdesc="Python bindings for chmlib"
arch=('loong64' 'x86_64')
url="https://github.com/dottedmag/pychm"
license=('GPL')
depends=('chmlib' 'python')
makedepends=('python-setuptools')
checkdepends=('python-pytest')
source=($pkgname-$pkgver.tar.gz::https://github.com/dottedmag/pychm/archive/v$pkgver.tar.gz)
sha256sums=('23cdc3bbbeb97b57b472a67a0c7c96c6f1ec2d684a73a69fa84aaaeb195cab6c')
b2sums=('fdf3c37eead60455fd5bde1638a010f2788074752f98c32cf4b3431b4a87b8893c23a9fa29995352b35b41f628b7026fdbfa6ff20b75e8a6efdf75fc2da3f67d')

build() {
  cd "$srcdir/pychm-$pkgver"

  python setup.py build
}

check() {
  cd "$srcdir/pychm-$pkgver"

  # do glob expansion in variable assignment
  pythonpaths=("$PWD/build/lib.linux-$CARCH"-cpython-3*)

  PYTHONPATH="${pythonpaths[0]}" pytest
}

package() {
  cd "$srcdir/pychm-$pkgver"

  python setup.py install --root="$pkgdir" --optimize=1 --skip-build
}
